﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace EF_Cord.Migrations
{
    public partial class S8 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "RolePowers",
                columns: table => new
                {
                    OId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RId = table.Column<int>(type: "int", nullable: false),
                    WId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RolePowers", x => x.OId);
                    table.ForeignKey(
                        name: "FK_RolePowers_Powers_WId",
                        column: x => x.WId,
                        principalTable: "Powers",
                        principalColumn: "WId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RolePowers_Roles_RId",
                        column: x => x.RId,
                        principalTable: "Roles",
                        principalColumn: "RId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_RolePowers_RId",
                table: "RolePowers",
                column: "RId");

            migrationBuilder.CreateIndex(
                name: "IX_RolePowers_WId",
                table: "RolePowers",
                column: "WId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "RolePowers");
        }
    }
}
